package cn.devices.security;

import cn.devices.entity.TbAdm;
import cn.devices.mapper.TbAdmMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class AuthUserService implements UserDetailsService {
    @Autowired
    private TbAdmMapper mapper;
    @Override
    public AuthUserDetail loadUserByUsername(String s) throws UsernameNotFoundException {
        TbAdm user =mapper.getByLoginName(s);
        if(user==null)
        {
            throw new UsernameNotFoundException("未找到用户名");
        }
        AuthUserDetail detail=new AuthUserDetail();
        detail.setUserId(user.getAdminId().toString());
        detail.setPassword(user.getLoginPass());
        detail.setUsername(user.getLoginName());


       return  detail;
    }



}
